package com.qf.controller;

import com.qf.pojo.Permission;
import com.qf.service.PermissionService;
import com.qf.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/permission")
public class PermissionController {
    @Autowired
    PermissionService permissionService;

    @GetMapping("/queryAllPermission")
    public ResultMsg queryAllPermission(@RequestParam(required = false) Integer page, @RequestParam(required = false, defaultValue = "10") Integer limit) {
        return permissionService.queryAllPermission(page, limit);
    }

    @GetMapping("/queryOnePermission")
    public ResultMsg queryOnePermission(@RequestParam(required = false) Integer permissionId) {
        return permissionService.queryOnePermission(permissionId);
    }

    @PutMapping("/updatePermission")
    public ResultMsg updatePermission(@RequestBody Permission permission) {
        return permissionService.updatePermission(permission);
    }

    @PutMapping("/insertPermission")
    public ResultMsg insertPermission(@RequestBody Permission permission) {
        return permissionService.insertPermission(permission);
    }
}
